package org.tinaelle.client.utils;

public class ErrorText extends Text {

	public final static String	STYLE_ERROR_TEXT	= "ErrorText";

	boolean	                   empty	         = true;

	public ErrorText() {
		super();
		setStyleName( STYLE_ERROR_TEXT );
	}

	public ErrorText(final String arg0) {
		super( arg0 );
		setStyleName( STYLE_ERROR_TEXT );
	}

	public ErrorText(final String arg0, final boolean arg1) {
		super( arg0, arg1 );
		setStyleName( STYLE_ERROR_TEXT );
	}

	public void addError(final String text) {
		empty = false;
		setText( getText() + "\n" + text );
	}

	public void addError(final Throwable t) {
		addError( ExceptionTool.extractUserMessage( t ) );
	}

	public void clear() {
		empty = true;
		setText( "" );
	}

	public boolean isEmpty() {
		return empty;
	}

}
